

#include <stdio.h>
#include <string.h>
#include "list.h"



struct game_item {
	char name[64];
};

#define MAX_HISTORY 10
struct game_history {
	int pos;
	int n;  // how many we collect
	struct game_item items[MAX_HISTORY];
};


struct game_history his_root;


static void history_init(struct game_history *root)
{
	root->pos = -1;
	root->n = 0;
}


static void history_add(struct game_history * root, struct game_item *item)
{
	root->pos += 1;
	if(root->pos >= MAX_HISTORY){
		root->pos = 0;
	}
	memcpy(&root->items[root->pos], item, sizeof(*item));
	if(root->n < MAX_HISTORY){
		root->n += 1;
	}

}

static void history_show(struct game_history *root)
{
	int i, j;
	for(i=0, j=root->pos; i<root->n; i++, j--){
		if(j<0){
			j=MAX_HISTORY-1;
		}
		printf("item %d: %s\n", i, root->items[j].name);
	}
}


int main(int ac, char *av)
{

	int name[64];
	int i;
	struct game_item item;
	history_init(&his_root);
	while(1){
		scanf("%s", item.name);
		history_add(&his_root, &item);
		history_show(&his_root);
	}

}
